<!DOCTYPE html>
<body>
<script src="../../../resources/js-test.js"></script>
<script>

description('This tests that Element implements the ParentNode interface.');

var element = document.createElementNS('foo', 'element');

shouldBe('element.children.length', '0');
shouldBe('element.childElementCount', '0');
shouldBeNull('element.firstElementChild');
shouldBeNull('element.lastElementChild');

element.appendChild(new Text('a'));
shouldBe('element.children.length', '0');
shouldBe('element.childElementCount', '0');
shouldBeNull('element.firstElementChild');
shouldBeNull('element.lastElementChild');

var b = element.appendChild(document.createElement('b'));
shouldBe('element.children.length', '1');
shouldBe('element.childElementCount', '1');
shouldBe('element.children[0]', 'b');
shouldBe('element.firstElementChild', 'b');
shouldBe('element.lastElementChild', 'b');

element.appendChild(new Text('c'));
shouldBe('element.children.length', '1');
shouldBe('element.childElementCount', '1');
shouldBe('element.children[0]', 'b');
shouldBe('element.firstElementChild', 'b');
shouldBe('element.lastElementChild', 'b');

var d = element.appendChild(document.createElement('d'));
shouldBe('element.children.length', '2');
shouldBe('element.childElementCount', '2');
shouldBe('element.children[0]', 'b');
shouldBe('element.children[1]', 'd');
shouldBe('element.firstElementChild', 'b');
shouldBe('element.lastElementChild', 'd');

element.appendChild(new Text('e'));
shouldBe('element.children.length', '2');
shouldBe('element.childElementCount', '2');
shouldBe('element.children[0]', 'b');
shouldBe('element.children[1]', 'd');
shouldBe('element.firstElementChild', 'b');
shouldBe('element.lastElementChild', 'd');

</script>
